package com.glasgowrax.hack.domain.directions;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class Directions {
	
	private String status;
	private List<Route> routes;
	
	public Directions(JSONObject json) {
		
		routes = new ArrayList<Route>();
		
		try {
			status = (json.has("status")) ? (String) json.get("status") : "";
			
			if (json.has("routes")) {
				JSONArray jsonRoutes = json.getJSONArray("routes");
				for (int i=0; i<jsonRoutes.length(); i++) {
					routes.add(new Route(jsonRoutes.getJSONObject(i)));
				}
			}
		
		} catch (JSONException e) {
			e.printStackTrace();
		}
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public List<Route> getRoutes() {
		return routes;
	}

	public void setRoutes(List<Route> routes) {
		this.routes = routes;
	}		
	
}
